#include "sceneParam.h"
#include "jsonUtils.h"

SceneParam::SceneParam() :doc(rapidjson::kObjectType), movieId(0), scene(0)
{

}

SceneParam::SceneParam(const int64_t& movieId, const int& scene):doc(rapidjson::kObjectType),movieId(movieId),scene(scene)
{

}

JsonDoc& SceneParam::jsonSerialize()
{
	jsonSerialize(doc,doc.GetAllocator());
	return doc;
}

JsonValue& SceneParam::jsonSerialize(JsonValue& v, JsonDoc::AllocatorType& allocator)
{
	v.AddMember(L"movieId", movieId, allocator);
	v.AddMember(L"scene", scene, allocator);
	return v;
}

JsonDoc& SceneParam::jsonDeserialize(const String& json)
{
	doc.Parse(json.c_str());
	if (!json.empty()) {
		jsonDeserialize(doc);
	}
	return doc;
}

const JsonValue& SceneParam::jsonDeserialize(const JsonValue& v)
{
	JsonUtils::loadLong(v, L"movieId", movieId);
	JsonUtils::loadInt(v, L"scene", scene);
	return v;
}

String SceneParam::jsonStr()
{
	jsonSerialize();
	return JsonUtils::jsonStr(doc);
}

const int64_t& SceneParam::getMovieId() const
{
	return movieId;
}

const int& SceneParam::getScene() const
{
	return scene;
}
